#include "fileLoader.h"

// This creates a new vector<string>* - be careful with memory
vector<string>* splitString(string toSplit, char splitChar) {
	vector<string>* splitVec = NULL;
	string splittingString = toSplit;

	//cout << "Starting string: \'" << splittingString << "\'";

	unsigned int splitCharLoc;
	while(string::npos!=(splitCharLoc=splittingString.find_first_of(splitChar))) {
		if(splitVec == NULL)
			splitVec = new vector<string>;

		//std::cout << "Split char loc: " << splitCharLoc << endl << endl;

		splitVec->push_back(splittingString.substr(0,splitCharLoc));

		string temp = splittingString.substr(splitCharLoc + 1,string::npos);
		splittingString = temp;

		//std::cout << "Split char loc: " << splitCharLoc << endl << "Split string: " << splitVec->back() << "---" << endl << "Splitting string: " << splittingString << ' ' << endl << "Split char index: " << splittingString.find_first_of(splitChar) << endl << endl;
	}

	// Add the remaining part of the string to the vector
	if((splittingString.length() > 0) && splittingString[0] != ' ')
		splitVec->push_back(splittingString);

	return splitVec;
}